home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Online / News / Thor / scripts / BBBS.NComm.script < prev    next >
Text File  |  1996-11-10  |  8KB  |  425 lines

  1. ; $VER: BBBS.NComm.script 4.1 (8.8.95)
  2. ; BBBS NComm Script for THOR
  3. ; By Eivind Nordseth, Ultima Thule Software
  4.  
  5.     REQUEST OFF
  6.  
  7.     set $fixtimeout = ""
  8.     set $rengrab = ""
  9.     set $doctrlx = "FALSE"
  10.     set $done = "FALSE"
  11.  
  12.     cli $THORPath"bin/ScriptServ \""$BBSName"\" WRITECFG EV 7 EV 8 EV 11 EV 12"
  13.  
  14.     if exists "t:NoLogOut" then cli "delete >nil: t:NoLogOut"
  15.     if exists "t:DoLogOut" then cli "delete >nil: t:DoLogOut"
  16.  
  17.     varfile "t:"$BBSName".CONFIG"
  18.  
  19.     readvar $CfgVer
  20.     readvar $BBSID
  21.     readvar $BBSType
  22.     readvar $Path
  23.     readvar $PostConf
  24.     readvar $UpLoadDir
  25.     readvar $UserName
  26.     readvar $UserStreet
  27.     readvar $UserAddress
  28.     readvar $UserCountry
  29.     readvar $UserPhone
  30.     readvar $NewFiles
  31.     readvar $AutoPDnl
  32.     readvar $AutoLogoff
  33.     readvar $UseColors
  34.     readvar $AnsiMenues
  35.     readvar $Bulletins
  36.     readvar $ReplyPacket
  37.     varfile close
  38.  
  39.     if !$CfgVer == "4" then message "Incompatible version of ScriptServ"
  40.     if !$CfgVer == "4" then goto AllDone
  41.  
  42.     if $ReplyPacket == "" then set $ReplyPacket = $BBSID".REP"
  43.  
  44.     cli "delete >nil: \"t:"$BBSName".CONFIG\""
  45.  
  46.     set $LogFile = $Path"ScriptMsg.txt"
  47.  
  48.     when "\r\nNO CARRIER\r\n" goto AllDone
  49.  
  50.     autoxfer off ; Turn off G&R commands
  51.     autoup off   ; Turn off Zmodem autoupload
  52.     autodown on  ; Turn on Zmodem autodownload
  53.  
  54.     menuselect TRANSLATE 1 8 ; Use IBN character set
  55.     set $charset = "IBN"     ; Use IBN character set
  56.  
  57.     converse "FIRST name?" $UserName" Q\n"
  58.     converse "will echo):" "\p\n"
  59.  
  60.     when "--more--" send "C"
  61.     when "Trykk <enter>" send "\n"
  62.  
  63.     set $docmd = "CHAT N U L 0 MF 50 S IBN\n"
  64.     gosub DoCommand
  65.  
  66.     dwhen "Trykk <enter>"
  67.  
  68.     wait "Command"
  69.     set $doctrlx = "TRUE"
  70.  
  71.     if !exists "t:"$BBSName".EVENTS" then goto afterEvents
  72.     varfile "t:"$BBSName".EVENTS"
  73.  
  74. eventLoop:
  75.     set $done = "FALSE"
  76.  
  77.     readvar $eventnr
  78.     readvar $event
  79.  
  80.     if $eventnr == "EOF" then goto evLoopEnd
  81.     if $event   == "EOF" then goto evLoopEnd
  82.  
  83.     if $event == "7"  then gosub ConfigureBBS
  84.     if $event == "8"  then gosub SendUserInfo
  85.     if $event == "11" then gosub CommandEvent
  86.     if $event == "12" then gosub AutoLogOff
  87.  
  88.     if  $done == "TRUE" then cli "run >nil: "$THORPath"bin/ScriptServ \""$BBSName"\" DONE "$eventnr
  89.     if !$done == "TRUE" then cli "run >nil: "$THORPath"bin/ScriptServ \""$BBSName"\" ERROR "$eventnr
  90.  
  91.     goto eventLoop    
  92.  
  93. evLoopEnd:
  94.     varfile close
  95.  
  96. afterEvents:
  97.  
  98. ;***************** Set correct grab format
  99.  
  100.     set $docmd = "U GF H\n"
  101.     gosub DoCommand
  102.  
  103. ;***************** Send reply packet
  104.  
  105.     if !exists $UpLoadDir$ReplyPacket then goto AfterReplyPacket
  106.  
  107.     set $docmd = "Q MU\n"
  108.     gosub DoCommand
  109.  
  110.     set $reperr = "FALSE"
  111.     when "Hippo fatal error:" set $reperr = "TRUE"
  112.  
  113.     wait "Starting ZModem"
  114.     upload $UpLoadDir$ReplyPacket,Z
  115.     gosub NoTimeout
  116.  
  117.     capture $Path"HIPPOMsg.txt"
  118.  
  119.     wait "Main Command"
  120.  
  121.     capture off
  122.     dlwhen
  123.  
  124.     if $reperr == "TRUE" then goto RepFileFail
  125.  
  126.     cli "delete >nil: "$UpLoadDir$ReplyPacket
  127.     cli "delete >nil: "$Path"HIPPOMsg.txt"
  128.  
  129.     cli "run >nil: "$THORPath"bin/ScriptServ \""$BBSName"\" PACKAGEDONE"
  130.  
  131.     set $doctrlx = "TRUE"
  132.     goto AfterReplyPacket
  133.  
  134. RepFileFail:
  135.     set $appendsource = $Path"HIPPOMsg.txt"
  136.     set $appenddest = $LogFile
  137.     gosub AppendFile
  138.     set $doctrlx = "TRUE"
  139.  
  140. AfterReplyPacket:
  141. ;***************** Grab messages
  142.     set $rengrab = "y"
  143.  
  144.     set $docmd = "R DUMP ALL\n"
  145.     gosub DoCommand
  146.  
  147.     when "<0>" goto grabd
  148.  
  149.     converse "Command" "SE\n"
  150.     gosub NoTimeout
  151.  
  152.     set $rengrab = "y"
  153.  
  154. grabd:
  155.     dlwhen
  156.  
  157. ;***************** Ready for logout
  158.  
  159.     if exists "t:DoLogOut" then goto DoLogOut
  160.  
  161.     if $AutoLogoff == "n" then goto NoLogOut
  162.  
  163.     if exists "t:NoLogOut" then goto NoLogOut
  164.  
  165. DoLogOut:
  166.     set $docmd = "CHAT A U L 30 MF 0\n"
  167.     gosub DoCommand
  168.  
  169.     set $docmd = "G Y N Y\n"
  170.     gosub DoCommand
  171.  
  172.     when "\r\nNO CARRIER\r\n" goto Hanged
  173.     delay 2
  174.     repeat
  175.     hangup
  176.     delay 2
  177.     until !CARRIER
  178.  
  179. Hanged:
  180.     dlwhen
  181.     goto AllDone
  182.  
  183. NoLogOut:
  184.     set $docmd = "CHAT A U L 30 MF 0 W R\n"
  185.     gosub DoCommand
  186.  
  187.     dwhens
  188.     timeout 0
  189.  
  190. AllDone:
  191.     request on
  192.     end
  193.  
  194.  
  195. Hung:
  196.     beep
  197.     message "\nI think the board has hung."
  198.     message "\nTurn off this script within 20 seconds to stop me from logging out !!"
  199.     delay 20
  200.     beep
  201.     message "\nWARNING: Logout in progress.\n"
  202.     hangup
  203.     goto AllDone
  204.  
  205. SysOp:
  206.     send "Sorry, you are trying to chat with a script.\n"
  207.     send "Please put me back to the BBS at once.\n"
  208.     set $Timeouts = "0"
  209.     wait "SYSOP is going offline!"
  210.     set $Timeouts = "0"
  211.     return
  212.  
  213.  
  214. ;************************************************
  215. DoCommand:
  216.     if $doctrlx == "TRUE" then send "^Z"
  217.     converse "Command" $docmd
  218.  
  219.     if !$rengrab == "" then gosub RenameGrab
  220.     if !$fixtimeout == "" then gosub SetupTimeout
  221.  
  222.     set $doctrlx = "FALSE"
  223.     return
  224.  
  225. ;************************************************
  226. NoTimeout:
  227.     set $fixtimeout = "d"
  228.     timeout 0
  229.     return
  230.  
  231. SetupTimeout:
  232.     set $fixtimeout = ""
  233.     set $Timeouts = "0"
  234.     timeout 60 gosub SendCTRLX
  235.     return
  236.  
  237. SendCTRLX:
  238.     set $fixtimeout = "d"
  239.     if $Timeouts == "2" then timeout 20 gosub Hung
  240.     if $Timeouts == "2" then send "^Z"
  241.  
  242.     if $Timeouts == "1" then send $docmd
  243.     if $Timeouts == "1" then set $Timeouts = "2"
  244.  
  245.     if $Timeouts == "0" then send "^Z"
  246.     if $Timeouts == "0" then set $Timeouts = "1"
  247.     return
  248.  
  249. Hung:
  250.     beep
  251.     message "\nI think the board has hung."
  252.     message "\nTurn off this script within 20 seconds to stop me from logging out !!"
  253.     delay 20
  254.     beep
  255.     message "\nWARNING: Logout in progress.\n"
  256.     hangup
  257.     goto AllDone
  258.  
  259. ;************************************************
  260. RenameGrab:
  261.     set $rengrab = ""
  262.     cli $THORPath"bin/ScriptServ \""$BBSName"\" RENAMEGRAB"
  263.     cli "run >nil: sys:rexxc/rx 'address THOR.01 RESCAN'"
  264.     return
  265.  
  266. ;************************************************
  267. Startlogfile:
  268.     if !exists $LogFile then write $LogFile "Messages from script:\n"
  269.     write $LogFile "Error in event nr "$eventnr":\n"
  270.     return
  271.  
  272. ;************************************************
  273. ; Append a file to the en of the other.
  274. ; Uses variables:
  275. ;  $appendsource - File to append.
  276. ;  $appenddest   - Destination.
  277. AppendFile:
  278.     if !exists $appenddest then goto afNotExists
  279.  
  280.     cli "join >nil: \""$appenddest"\" \""$appendsource"\" TO \""$appenddest".tmp\""
  281.     cli "delete >nil: \""$appenddest"\""
  282.     cli "rename >nil: \""$appenddest".tmp\" \""$appenddest"\""
  283.     cli "delete >nil: \""$appendsource"\""
  284.     return    
  285.  
  286. afNotExists:
  287.     cli "rename >nil: \""$appendsource"\" \""$appenddest"\""
  288.     return
  289.  
  290.  
  291. ;************************************************
  292. ; Do a custom command
  293. ; Uses variables:
  294. ;  $commandstring - Command to execute.
  295. CommandEvent:
  296.     readvar $commandstring
  297.  
  298.     write $LogFile "Executing custom command:\n"
  299.  
  300.     set $docmd = $commandstring"\n"
  301.     gosub DoCommand
  302.  
  303.     capture $LogFile
  304.  
  305.     gosub NoTimeout
  306.  
  307.     when "File Command"  goto CmdEvDone
  308.     when "Main Command"  goto CmdEvDone
  309.     when "Utility Command" goto CmdEvDone
  310.     when "SYSOP Command" goto CmdEvDone
  311.     when "SIGOP Command" goto CmdEvDone
  312.     when "Misc Command"  goto CmdEvDone
  313.     
  314.     wait "Read Command"
  315.  
  316. CmdEvDone:
  317.     dlwhen
  318.     dlwhen
  319.     dlwhen
  320.     dlwhen
  321.     dlwhen
  322.     dlwhen
  323.  
  324.     capture off
  325.     write $LogFile "\n"
  326.     set $done = "TRUE"
  327.     set $doctrlx = "TRUE"
  328.     return
  329.  
  330. ;************************************************
  331. ; Send user info
  332. ; Uses variables:
  333. ;    $msgfile    - file user info is in
  334. SendUserInfo:
  335.     readvar $msgfile
  336.  
  337.     set $docmd = "U RES\n"
  338.     gosub DoCommand
  339.  
  340.     wait "--7-"
  341.     send "^KC"
  342.  
  343.     ascsend $Path$msgfile
  344.     send "\w^Z"
  345.  
  346.     wait "Command"
  347.  
  348.     set $done = "TRUE"
  349.     set $doctrlx = "TRUE"
  350.  
  351.     return
  352.  
  353. ;************************************************
  354. ; Set up BBS configuration
  355. ConfigureBBS:
  356.  
  357.     set $docmd = "U TE ANSI\n"
  358.     gosub DoCommand
  359.  
  360.     set $docmd = "COL\n"
  361.     set $cfgset = $UseColors
  362.     gosub CfgEnable    
  363.  
  364.     set $docmd = "ED FSE\n"
  365.     gosub DoCommand
  366.  
  367.     set $docmd = "REV\n"
  368.     set $cfgset = "y"
  369.     gosub CfgEnable    
  370.  
  371.     set $docmd = "T Z\n"
  372.     gosub DoCommand
  373.     
  374.     set $docmd = "AF L\n"
  375.     gosub DoCommand
  376.  
  377.     set $docmd = "U A\n"
  378.     gosub DoCommand
  379.  
  380.     converse "street address" "^Z"$UserStreet"\n"
  381.     converse "code and state" "^Z"$UserAddress"\n"
  382.     
  383.     if $UserPhone == "" then set $UserPhone = "-"
  384.     converse "your phone number" "^Z"$UserPhone"\n"
  385.  
  386.     converse "date of birth" "\n"
  387.  
  388.     set $docmd = "R MODE Mark\n"
  389.     gosub DoCommand
  390.  
  391.     wait "Command"
  392.  
  393.     set $done = "TRUE"
  394.     set $doctrlx = "TRUE"
  395.  
  396.     return
  397.  
  398. CfgEnable:
  399.     set $scfenabled = "n"
  400.     when "enabled" set $scfenabled = "y"
  401.  
  402.     gosub DoCommand
  403.  
  404.     wait "Command"
  405.     dlwhen
  406.  
  407.     set $doctrlx = "TRUE"
  408.     if !$scfenabled == $cfgset then gosub DoCommand
  409.  
  410.     return
  411.  
  412. ;************************************************
  413. ; Set the autologoff flag.
  414. ; Uses variables:
  415. ;  $boolean - Logoff (y/n)
  416. AutoLogOff:
  417.     readvar $boolean
  418.  
  419.     set $AutoLogoff = "y"
  420.     if $boolean == "0" then set $AutoLogoff = "n"
  421.     set $done = "TRUE"
  422.  
  423.     return
  424.  
  425.